<%-- 
    Document   : ReportDS
    Created on : Nov 4, 2011, 12:34:47 PM
    Author     : Admin
--%>

<%@page import="net.sf.jasperreports.engine.design.JasperDesign"%>
<%@page import="net.sf.jasperreports.engine.xml.JRXmlLoader"%>
<%@page import="com.mysql.jdbc.Connection"%>
<%@page import="net.sf.jasperreports.engine.JasperExportManager"%>
<%@page import="net.sf.jasperreports.engine.JREmptyDataSource"%>
<%@page import="net.sf.jasperreports.engine.JasperFillManager"%>
<%@page import="net.sf.jasperreports.engine.JasperPrint"%>
<%@page import="net.sf.jasperreports.engine.JasperReport"%>
<%@page import="net.sf.jasperreports.engine.JRRuntimeException"%>
<%@page contentType="application/pdf" %>


<%@page trimDirectiveWhitespaces="true"%>

<%@page import="net.sf.jasperreports.engine.data.AbstractXmlDataSource"%>
<%@page import="model.util.MySQLProviders"%>

<%@page import="net.sf.jasperreports.engine.*" %>
<%@page import="net.sf.jasperreports.engine.util.*" %>
<%@page import="net.sf.jasperreports.engine.export.*" %>
<%@page import="net.sf.jasperreports.j2ee.servlets.*" %>
<%@page import="java.util.*" %>
<%@page import="java.io.*" %>

<%
    MySQLProviders helper = new MySQLProviders();
    helper.open();
    File reportFile = new File(application.getRealPath("/DanhSachPhieu.jrxml"));
    if (!reportFile.exists())
            throw new JRRuntimeException("File not found. The report design must be compiled first.");
  
    JasperDesign jasperDesign = JRXmlLoader.load(reportFile.getPath());
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    
   // JasperReport jasperReport = (JasperReport) JRLoader.loadObject(reportFile);
    Map parameters = new HashMap();
    parameters.put("imageRealPath", application.getRealPath("/"));
    JasperPrint jasperPrint = 
            JasperFillManager.fillReport(
                   jasperReport, 
                    parameters, 
                   // new JREmptyDataSource()
                    helper.getConnection()
                    );
    
    JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
    helper.close();
%>


